//
//  SMLoctionManager.h
//  DiDi
//
//  Created by huangtie on 2017/3/19.
//  Copyright © 2017年 Sinmore. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

typedef NS_ENUM(NSUInteger, SMThirdMap_Code) {
    SMThirdMap_Code_GD,         //高德地图
    SMThirdMap_Code_BD,         //百度地图
    SMThirdMap_Code_TX,         //腾讯地图
    SMThirdMap_Code_AP,         //苹果自带地图
};

NS_ASSUME_NONNULL_BEGIN

typedef void (^SMRequestLocationCompletion)(CLLocation * __nullable location, NSError * __nullable error);
typedef void (^SMRequestPlacemarkCompletion)(CLPlacemark * __nullable placemark,CLLocation * __nullable location, NSError * __nullable error);

@interface SMLoctionManager : NSObject

/**
 * 上一次获取到的定位, CLLocation对象或者nil
 */
@property (readonly, nonatomic, nullable) CLLocation *lastLocation;

/**
 * 上一次逆向解出的位置, CLPlacemark对象或者nil
 */
@property (readonly, nonatomic, nullable) CLPlacemark *lastPlacemark;

/**
 * 用户是否允许定位
 */
@property (readonly, nonatomic, getter=isAuthorized) BOOL authorized;

/**
 * 单例
 */
+ (instancetype)sharedInstance;

/**
 * 请求坐标
 */
- (void)requestLocation:(SMRequestLocationCompletion)completion;

/**
 * 请求地理位置
 */
- (void)requestPlacemark:(SMRequestPlacemarkCompletion)completion;

/**
 * 上传地理位置信息到服务器
 */
- (void)uploadLocation:(CLLocationCoordinate2D)coordinate
            completion:(void (^)(BOOL isucess))completion;

// 百度坐标转高德坐标
+ (CLLocationCoordinate2D)GCJ02FromBD09:(CLLocationCoordinate2D)coor;

// 高德坐标转百度坐标
+ (CLLocationCoordinate2D)BD09FromGCJ02:(CLLocationCoordinate2D)coor;

// 跳转第三方地图
+ (BOOL)callThirdMapApp:(SMThirdMap_Code)appCode
              starCoord:(CLLocationCoordinate2D)starCoord
             endAddress:(NSString *)endAddress
               endCoord:(CLLocationCoordinate2D)endCoor;

@end

NS_ASSUME_NONNULL_END
